package com.eshore.norm.pattern.command;

import java.util.Map;
import java.util.Set;

/**
 * ConcreteCommand(具体的命令)：ConcreteCommand角色负责实现在Command角色中定义的接口(API)。聚合接收者，将一个接收者对象与一个动作绑定，调用接收者相应的操作来实现execute
 *
 * @author: v-chenjl62
 * @date: 2024/2/7 10:10
 */
public class OderCommand implements Command {
    private SeniorChef seniorChef;
    private Order order;

    public OderCommand(SeniorChef seniorChef, Order order) {
        this.seniorChef = seniorChef;
        this.order = order;
    }

    @Override
    public void execute() {
        System.out.println(order.getDiningTable()+"号桌订单如下：");
        //foodDir必须有值，考虑在Client赋值，用order.setFoodDir
        Map<String, Integer> foodDir = order.getFoodDir();
        Set<Map.Entry<String, Integer>> entries = foodDir.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            seniorChef.makeFood(entry.getValue(),entry.getKey());
        }
        System.out.println("================");
    }
}
